import 'package:flutter/material.dart';

// ignore: must_be_immutable
class ShopGradeItem extends StatefulWidget {
  var selectValue;
  final gradeitem;
  final ValueChanged grade;
  ShopGradeItem(
      {Key key,
      @required this.gradeitem,
      @required this.selectValue,
      @required this.grade})
      : super(key: key);

  @override
  _ShopGradeItemState createState() => _ShopGradeItemState();
}

class _ShopGradeItemState extends State<ShopGradeItem> {
  @override
  void initState() {
    super.initState();
    widget.selectValue = getListData()[0].value;
  }

  List<DropdownMenuItem> getListData() {
    List<DropdownMenuItem> items = new List();
    DropdownMenuItem dropdownMenuItem1 = new DropdownMenuItem(
      child: new Text('  5  '),
      value: 5,
    );
    items.add(dropdownMenuItem1);
    DropdownMenuItem dropdownMenuItem2 = new DropdownMenuItem(
      child: new Text('  4   '),
      value: 4,
    );
    items.add(dropdownMenuItem2);
    DropdownMenuItem dropdownMenuItem3 = new DropdownMenuItem(
      child: new Text('  3   '),
      value: 3,
    );
    items.add(dropdownMenuItem3);
    DropdownMenuItem dropdownMenuItem4 = new DropdownMenuItem(
      child: new Text('  2   '),
      value: 2,
    );
    items.add(dropdownMenuItem4);
    DropdownMenuItem dropdownMenuItem5 = new DropdownMenuItem(
      child: new Text('  1   '),
      value: 1,
    );
    items.add(dropdownMenuItem5);
    return items;
  }

  @override
  Widget build(BuildContext context) {
    return Row(
      children: [
        Container(
          child: Text('${widget.gradeitem}:'),
          padding: EdgeInsets.only(right: 15),
        ),
        Container(
          child: DropdownButton(
            items: getListData(),
            icon: Icon(Icons.keyboard_arrow_down),
            onChanged: (value) {
              setState(() {
                widget.selectValue = value;
                widget.grade(value);
              });
            },
            value: widget.selectValue,
          ),
        )
      ],
    );
  }
}

class MedicineKindItem extends StatefulWidget {
  MedicineKindItem({Key key, this.getkindValue}) : super(key: key);
  final ValueChanged getkindValue;

  @override
  _MedicineKindItemState createState() => _MedicineKindItemState();
}

class _MedicineKindItemState extends State<MedicineKindItem> {
  var selectValue;
  @override
  void initState() {
    super.initState();
    selectValue = getListData()[0].value;
  }

  List<DropdownMenuItem> getListData() {
    List<DropdownMenuItem> items = new List();
    DropdownMenuItem dropdownMenuItem1 = new DropdownMenuItem(
      child: new Text('清热解毒'),
      value: 2,
    );
    items.add(dropdownMenuItem1);
    DropdownMenuItem dropdownMenuItem2 = new DropdownMenuItem(
      child: new Text('消炎止咳'),
      value: 3,
    );
    items.add(dropdownMenuItem2);
    DropdownMenuItem dropdownMenuItem3 = new DropdownMenuItem(
      child: new Text('其他'),
      value: 4,
    );
    items.add(dropdownMenuItem3);
    return items;
  }

  @override
  Widget build(BuildContext context) {
    return Row(
      children: [
        Container(
          child: Text('类别'),
          padding: EdgeInsets.only(right: 15),
        ),
        Container(
          child: DropdownButton(
            items: getListData(),
            icon: Icon(Icons.keyboard_arrow_down),
            onChanged: (value) {
              setState(() {
                selectValue = value;
                widget.getkindValue(value);
              });
            },
            value: selectValue,
          ),
        )
      ],
    );
  }
}

class MedicineIdentity extends StatefulWidget {
  final ValueChanged getidentityValue;
  MedicineIdentity({Key key, this.getidentityValue}) : super(key: key);

  @override
  _MedicineIdentityState createState() => _MedicineIdentityState();
}

class _MedicineIdentityState extends State<MedicineIdentity> {
  var selectValue;
  @override
  void initState() {
    super.initState();
    selectValue = getListData()[0].value;
  }

  List<DropdownMenuItem> getListData() {
    List<DropdownMenuItem> items = new List();
    DropdownMenuItem dropdownMenuItem1 = new DropdownMenuItem(
      child: new Text('是'),
      value: 0,
    );
    items.add(dropdownMenuItem1);
    DropdownMenuItem dropdownMenuItem2 = new DropdownMenuItem(
      child: new Text('否'),
      value: 1,
    );
    items.add(dropdownMenuItem2);
    return items;
  }

  @override
  Widget build(BuildContext context) {
    return Row(
      children: [
        Container(
          child: Text('是否为处方'),
          padding: EdgeInsets.only(right: 15),
        ),
        Container(
          child: DropdownButton(
            items: getListData(),
            icon: Icon(Icons.keyboard_arrow_down),
            onChanged: (value) {
              setState(() {
                selectValue = value;
                widget.getidentityValue(value);
              });
            },
            value: selectValue,
          ),
        )
      ],
    );
  }
}
